<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    {{login.username}}
</div>
<script src="/js/vue.js"></script>
<script>
    const app = Vue.createApp({
        data() {
            return {
                login: {
                    username: undefined,
                    id: undefined
                }
            }
        },
        methods: {
            getUser() {
                // 获取登录成功的用户信息
                let user = sessionStorage.getItem("loginUser")
                this.login = user ? JSON.parse(user) : null
            }
        }
    })
    const vm = app.mount("#app")
    vm.getUser()
</script>
</body>
</html>